import requests
import json

url = "http://gateway.fengjinketang.com/api/hs-global-user-web/v1/getUserAllMessage"
headers = {
    'Token': 'lwl',
    'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
    'Content-Type': 'application/json'
}


def change_id(userids=None, sourceuserids=None):
    if userids is not None:
        print(str(len(userids)) + '条数据')
        for i in userids:
            payload = json.dumps({
                "data": {
                    "userId": i,
                    "sourceUserId": ''
                }
            })

            response = requests.request("POST", url, headers=headers, data=payload)
            print(i, response.json()['data']['fjUserInfoResult']['id'])
    elif sourceuserids is not None:
        print(str(len(sourceuserids)) + '条数据')
        for i in sourceuserids:
            payload = json.dumps({
                "data": {
                    "userId": '',
                    "sourceUserId": i
                }
            })

            response = requests.request("POST", url, headers=headers, data=payload)
            print(i, response.json()['data']['tokenCacheResult']['userId'])


if __name__ == '__main__':
    userids = ["uid_596362475625938945",
               "uid_596029923409125378",
               "uid_565643213097099397",
               "uid_638117986961444866",
               "uid_638117986961444866",
               "uid_565642694760816886",
               "uid_565642694760816886",
               "uid_638117986961444866",
               "uid_638117986961444866",
               "uid_638117986961444866",
               "uid_565641731610206440",
               "uid_638117986961444866",
               "uid_690923805760385026",
               "uid_565641571568148550",
               "uid_565641889513169277",
               "uid_565641278159806738",
               "uid_565641731610206440",
               "uid_565642694760816886",
               "uid_565641723930435856",
               "uid_565642420499472574",
               "uid_565643687573545007",
               "uid_565641630468759775",
               "uid_565643664571981829",
               "uid_565643664571981829",
               "uid_787059563811962881",
               "uid_565643307838038096",
               "uid_787059563811962881",
               "uid_684305455705571329",
               "uid_565643582468481145",
               "uid_565643346257862728",
               "uid_565641505780490526",
               "uid_565641505780490526",
               "uid_565641505780490526",
               "uid_565641723930435856",
               "uid_565641723930435856",
               "uid_565642694760816886",
               "uid_604631471978954753",
               "uid_565642503701880913",
               "uid_565642056429690975",
               "uid_565642503701880913"]
    sourceuserids = ["u2206100100480NFJLc374",
                     "u220324194132K1z96z132",
                     "u220516091957mxJJCT387",
                     "u220516041139tnXJ7s111",
                     "u2202171843000SGDKU218",
                     "u220516063840EqqD7Q122",
                     "u220217175301pIHb4p177",
                     "u240101110259RuvmCd154",
                     "u220208160035000000222",
                     "u230111073611Io4O1r132",
                     "u230903170651LckhPO169",
                     "u220515195800PcSgwP354",
                     "u220516053158jmEKaY125",
                     "u220407183304sA2Ltn109",
                     "u231125055446IWSGOj193",
                     "u231231194630bvQ1EN182",
                     "u230510113522RGsfUz116",
                     "u220516090356WYJq03166",
                     "u220208174553000000221",
                     "u240103191835HriqXu173",
                     "u220626130510GDyQYS111",
                     "u231129152121aUkOli107"]
    # userids 与 sourceuserids 二选一
    change_id(userids=userids)
